package org.jbit.news.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.jbit.news.biz.NewsBiz;
import org.jbit.news.biz.impl.NewsBizImpl;
import org.jbit.news.entity.News;

public class NewsUpdateServlet extends HttpServlet{

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
   		response.setCharacterEncoding("utf-8");
   		String nid=request.getParameter("nid");
   		NewsBiz nb = new NewsBizImpl();
   		List<News> list=nb.getNewsByNid(Integer.parseInt(nid));
   		for(News news:list){
   			request.setAttribute("ntid", news.getNtid());
   			request.setAttribute("ntitle", news.getNtitle());
   			request.setAttribute("nauthor", news.getNauthor());
   			request.setAttribute("nsummary", news.getNsummary());
   			request.setAttribute("ncontent", news.getNcontent());
   		}
   		request.getRequestDispatcher("../newspages/news_add.jsp?xg=xiugai&nid="+nid+"").forward(request, response);
    
	}
	
}
